<?php

	if (!defined('EXPONENT')) exit('');
	if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate"),$loc))
	{
		exponent_flow_set(SYS_FLOW_PROTECTED,SYS_FLOW_ACTION);
		require_once(BASE."modules/formhelpermodule/formhelper.php");

		$formhelper=new formhelper("filemanagermodule","_manager_user_title","_manager_user_title",$loc);
		$formhelper->setGridType(FORMHELPER_GRID_TYPE_DATAGRID);
		$formhelper->setGridOptions("height",500);
		$formhelper->setGridOptions("idField","id");
		$formhelper->setGridOptions("pagination",1);
		$formhelper->setGridOptions("pageNumber","1");
		$formhelper->setGridOptions("pageSize","20");
		$formhelper->setGridOptions("rownumbers","true");
		$formhelper->setGridID("filemanager_users");
		//$formhelper->setInitCallback("Manageuser_Init");
		
		$js=URL_FULL."modules/filemanagermodule/js/Manager_User.js";
		$formhelper->addJS($js);
		
		$formhelper->setColumnType(1);
		$formhelper->addColumn(array("field"=>"user_id","title"=>"User ID",'width'=>50));
		$formhelper->addColumn(array("field"=>"username","title"=>"User Name",'width'=>110));
		$formhelper->addColumn(array("field"=>"homedir","title"=>"Home",'width'=>120));
		$formhelper->addColumn(array("field"=>"show_hidden","title"=>"Show hidden",'width'=>80,'align'=>'center', 'formatter'=>"function(value, row, index){if (value==0) return 'No'; else return 'Yes';}"));
		$formhelper->addColumn(array("field"=>"pattern_hidden","title"=>"Pattern hidden",'width'=>90));
		$formhelper->addColumn(array("field"=>"permissions","title"=>"Permissions",'width'=>100,'formatter'=>"function(value, row, index){if (value==0) return 'View only'; else if (value==1) return 'Modify'; else if (value==2) return 'Change password'; else if (value==3) return 'Modify & Change password'; else return 'Administrator';}"));
		$formhelper->addColumn(array("field"=>"active","title"=>"Active",'width'=>50,'align'=>'center','formatter'=>"function(value, row, index){if (value==0) return 'No'; else return 'Yes';}"));
		
		$link_param="/index.php?module=filemanagermodule&action=manager_user_getjson&src={$loc->src}&ajax_action=1";
		$formhelper->setURLDataStream($link_param);
		
		$formhelper->setGridOptions("onBeforeLoad","function(___form_onBeforeLoad");
		$formhelper->setGridOptions("onSelect","function(___Manage_User_OnSelect");
		$toolbar_template=new template("filemanagermodule","_Manager_User_ToolbarHTML",$loc);
		$toolbar_template->register_permissions(array('administrate',"configure"),$loc);
		$toolbar_html=$toolbar_template->render();
		$formhelper->addToolbarHTML($toolbar_html);
		$formhelper->register_permissions(array('administrate',"configure"),$loc);
		$formhelper->output();
	}
	else
	{
		echo exponent_http_error(403);
	}
?>
